
module VersionControl

  def self.random_token len = 36
    Tokenizer.token len
  end

  class Tokenizer

    def self.token len = 36
      max = 36**len
      # 10 + rand(100 - 10) will allways have expected length
      (max/10 + rand(max - max / 10)).to_s 36
    end
    
    class Test < FwTest
      def test_guid_default_length
        eq VersionControl.random_token.length, 36
      end

      def test_guid_accepts_length_parameter
        eq VersionControl.random_token(17).length, 17
      end
    end

  end


end
